package me.zhenqu.model.dao.impl;

import me.zhenqu.model.dao.FollowShipDao;
import me.zhenqu.model.pojo.entity.FollowShip;
import org.springframework.stereotype.Repository;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: yibing.tan
 * Date: 11-11-10
 * Time: 下午5:18
 * To change this template use File | Settings | File Templates.
 */
@Repository("followShipDao")
public class FollowShipDaoImpl extends ZhenquDaoHelper<FollowShip> implements FollowShipDao {
    @Override
    public FollowShip findByID(Long id) {
        return null;
    }

    public List<FollowShip> findAllFollowingShips(Long user_id){
        return getHibernateTemplate().find("from FollowShip where user_id=? order by createTime desc",user_id);
    }

    @Override
    public List<FollowShip> findAllFollowedShips(Long user_id) {
        return getHibernateTemplate().find("from FollowShip where follow_user_id=? order by createTime desc",user_id);
    }

    @Override
    public boolean findBySample(FollowShip fs) {
        List list = getHibernateTemplate().find("from FollowShip where user_id=? and follow_user_id=?",fs.getUser_id(), fs.getFollow_user_id());
        if (list==null||list.isEmpty()) return false;
        return true;
    }
}
